﻿
//DavidLee 2019/12/17
//TinyMCE plugin for netcorecms
//根据项目需要定制tinymce插件，将tinymce编辑器中选中的图片设置为文章的封面图片
(function (domGlobals) {
    'use strict';
    // 获取插件管理对象
    //tinymce plugin example :https://codesandbox.io/embed/tinymce-dialog-openurl-demo-fpfew
    var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
    global$1.add('setascoverimg', function (editor, url) {
        editor.ui.registry.addButton('setascoverimg', {
            text: 'SetCoverImage',
            onAction: () => {
                var selectImg = editor.selection.getNode();
                if (selectImg.nodeName !== "IMG")
                    editor.windowManager.alert("请在编辑器中选择图片！");
                else {
                    $('body').trigger("tinymce.setascoverimg", selectImg);
                }

            }
        });
        return {
            getMetadata: function () {
                return {
                    name: "SetCoverImage",
                    url: "http://exampleplugindocsurl.com"
                };
            }
        };
    });

}(window));
